//
//  YXTViewController.m
//  YXTNetworking
//
//  Created by hanjun on 05/10/2016.
//  Copyright (c) 2016 hanjun. All rights reserved.
//

#import "YXTViewController.h"
#import "YXTNetworking.h"
#import "MJExtension.h"

@interface YXTViewController ()
@property (weak, nonatomic) IBOutlet UITextView *returnTV;

@end

@implementation YXTViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    [[YXTNetworking getInstance] configPlatform:PlatformTypeLeCaiVIP apiEnvironment:APIEnvironmentProduction orgCode:@""];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)action:(id)sender {
    [[YXTNetworking getInstance] checkAppVersionWithSuccess:^(NSURLSessionDataTask *task, id response) {
        _returnTV.text = [response mj_JSONString];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error){
        id data = error.userInfo[@"com.alamofire.serialization.response.error.data"];
        NSHTTPURLResponse * response = error.userInfo[@"com.alamofire.serialization.response.error.response"];
        id responseObject = [data mj_JSONObject];
        NSLog(@"checkAppVersionWithSuccess:statusCode:%ld,responseObject:%@",response.statusCode, responseObject);
    }];

    
    [[YXTNetworking getInstance] searchPublicRoomList:nil success:^(NSURLSessionDataTask *task, id response) {
        
    } failure:^(NSURLSessionDataTask * task, NSError * error) {
        id data = error.userInfo[@"com.alamofire.serialization.response.error.data"];
        NSHTTPURLResponse * response = error.userInfo[@"com.alamofire.serialization.response.error.response"];
        id responseObject = [data mj_JSONObject];
        NSLog(@"searchPublicRoomList:statusCode:%ld,responseObject:%@",response.statusCode, responseObject);
    }];
}

@end
